package com.sanyang.logistics.sch.handler;





import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.support.DaoSupport;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sanyang.logistics.pojo.Region;
import com.sanyang.logistics.pojo.Role;
import com.sanyang.logistics.pojo.SysUser;
import com.sanyang.logistics.sch.service.LoginService;



@Controller
@RequestMapping("/login")
public class LoginHandler {
	
	
	@Autowired
	private	LoginService service;
	
	@RequestMapping("/all")
	@ResponseBody
	public Object all(SysUser sysUser) {  
			SysUser all = service.all(sysUser);
			System.out.println(123);
			if (all==null) {
				System.out.println("1212");
				return 1;
			}
			System.out.println(sysUser);
			return all;
	
	}	  
	
	@RequestMapping("/loginall")
	@ResponseBody
	public Object loginall(SysUser sysUser) {
		  List<SysUser> loginall = service.loginall(sysUser);
		return loginall;
	}
	
	@RequestMapping("/logindele")
	@ResponseBody
	public String logindele(Integer user_id) {
		service.logindele(user_id);
		return "del";
	}
	
	@RequestMapping("/roleall")
	@ResponseBody
	public Object roleall() {
		List<Role> roleall = service.roleall();
		return roleall;
	}
	
	@RequestMapping("/loginadd")
	@ResponseBody
	public Object loginadd(SysUser sysUser) {
		service.loginadd(sysUser);
			return "add";
	}
	
	@RequestMapping("/loginse")
	@ResponseBody
	public Object loginse(Integer user_id) {
		SysUser loginse = service.loginse(user_id);
		return loginse;
	}
	
	@RequestMapping("/loginup")
	@ResponseBody
	public String loginup(SysUser sysUser) {
		service.loginup(sysUser);
		return "up";
		
	}
	
	@RequestMapping("/regionall")
	@ResponseBody
	public Object regionall() {
		List<Region> regionall = service.regionall();
		return regionall;
	}
	
	@RequestMapping("/loginuserjudgment")
	@ResponseBody
	public Object loginuserjudgment(SysUser sysUser) {
		List<SysUser> loginuserjudgment = service.loginuserjudgment(sysUser);
		if (loginuserjudgment.size()>0) {
			return "1";
		}else {
			return "0";
		}
	}
	
	
	

}
